package com.rsy.ware.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author hl
 * @Data 2020/7/22
 */
@Configuration
@EnableTransactionManagement //开启事务
public class MybatisConfig {

//    /**
//     * mp 分页插件
//     *
//     * @return
//     */
//    @Bean
//    public PaginationInterceptor paginationInterceptor() {
//        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
//        // 设置请求的页面，true为回到首页，false为继续请求
//        paginationInterceptor.setOverflow(true);
//        // 每页最大为1000条 （默认500）
//        paginationInterceptor.setLimit(1000);
//        return paginationInterceptor;
//    }
// 最新版
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }
}
